#include "mapper_factory.hpp"
#include "log.hpp"

namespace NES {
	/// Create a mapper for the given cartridge with optional callback function
	///
	/// @param game the cartridge to initialize a mapper for
	/// @param callback the callback function for the mapper (if necessary)
	///
	Mapper * NES::MapperFactory(Cartridge * game, std::function<void(void)> callback) {
		switch (static_cast<MapperID>(game->getMapper())) {
		case MapperID::NROM:
			LOG(InfoVerbose) << "NROM" << std::endl;
			return new MapperNROM(game);
		case MapperID::SxROM:
			LOG(InfoVerbose) << "SxROM" << std::endl;
			return new MapperSxROM(game, callback);
		case MapperID::UxROM:
			LOG(InfoVerbose) << "UxROM" << std::endl;
			return new MapperUxROM(game);
		case MapperID::CNROM:
			LOG(InfoVerbose) << "CNROM" << std::endl;
			return new MapperCNROM(game);
		default:
			return nullptr;
		}
	}
}